cmake_minimum_required(VERSION 3.0.2)
project(kybot_exception)
add_compile_options(-std=c++14)

find_package(catkin REQUIRED
roscpp
std_msgs
message_generation
roslib
kybot_msg
)

find_library(GLOG_LIBRARY
  NAMES glog
  PATHS /usr/lib /usr/lib/x86_64-linux-gnu  # 常见库路径
  NO_DEFAULT_PATH
)

if(NOT GLOG_LIBRARY)
  message(FATAL_ERROR "glog library not found. Install with: sudo apt install libgoogle-glog-dev")
endif()


generate_messages(DEPENDENCIES
  std_msgs 
  kybot_msg
)

catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS message_runtime message_generation message_runtime 
)

include_directories(
include ${catkin_INCLUDE_DIRS}
)

add_executable(${PROJECT_NAME}_node 
src/exceptionNode.cpp
src/robotException.cpp
)

target_link_libraries(${PROJECT_NAME}_node
  ${catkin_LIBRARIES}
  ${GLOG_LIBRARY}
)

# 设置安装目录 deb打包安装
# set(CMAKE_INSTALL_PREFIX "/home/kybot/kybot_ws/src")


# # Mark executables and/or libraries for installation
# install(TARGETS ${PROJECT_NAME}_node
#   ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib
#   LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib
#   RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/bin
# )

# install(DIRECTORY include/${PROJECT_NAME}/
#    DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/include
#    FILES_MATCHING PATTERN "*.h"
#    PATTERN ".svn" EXCLUDE
#  )

# install(DIRECTORY launch/
#     DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/launch
# )

# install(FILES  exceptionList.json
#     DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/
# )
# 设置安装目录 install 安装
set(CMAKE_INSTALL_PREFIX "/home/kybot/daimachonggou/install")
install(TARGETS ${PROJECT_NAME}_node               # 要安装的包的名称，由同文件中add_executable生成
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib     #静态库的安装路径
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib     #动态库的安装路径
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}    #可执行文件的安装路径
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE   #设置可执行文件的用户权限
)
#启动和配置文件目录
install(DIRECTORY launch data param    # 要安装的目录可以自由增添
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}   #安装目录的目的路径
)
